// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/visitor/api/VisitorAppointmentRecordApi'

import ComClass from '@api/ComQuery'
import ListClass from '@api/visitor/model/QueryVisitorAppointmentRecordListReq'
import OneClass from '@api/visitor/model/QueryVisitorAppointmentRecordDetailReq'

const CLIENT = CORE.grpcCLIENT(Client)

const COM = [ComClass, 'comQuery']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '查询列表') {
    const DTO = CORE.grpcDTO(ListClass, param, COM)
    const resp = await CORE.grpc(TIP, CLIENT, 'queryVisitorAppointmentList', DTO)
    return [resp.comQuery.totalCount, resp.content || []]
  },

  // —————————————————————————————— 单项 —————————————————————————————— //

  async getOne({ id }, TIP = '查询详情') {
    const DTO = CORE.grpcDTO(OneClass, { visitorAppointmentId: id })
    const resp = await CORE.grpc(TIP, CLIENT, 'queryVisitorAppointmentRecordDetail', DTO)
    return { ...resp.visitorAppointmentDto, partner: resp.content || [] }
  },
}
